//
//  ViewController.m
//  24-加密
//
//  Created by dllo on 16/8/16.
//  Copyright © 2016年 DM.C. All rights reserved.
//

#import "ViewController.h"
#import "NSString+DM_MD5.h"
#import "NSString+DM_SHA_1.h"
#import "NSString+DM_Base64.h"
#import "NSString+DM_DES.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // MD5 SHA-1 单向散列函数, 算法
    
    
    /************* 1.MD5 验证算法, 一般应用于验证密码 ***************/
    NSString *afterMD5 = @"Hello";
    NSString *finalMD5_32Lower = [afterMD5 stringWith32Bit_MD5Lower];
    NSString *finalMD5_32Upper = [afterMD5 stringWith32Bit_MD5Upper];
    NSString *finalMD5_16Lower = [afterMD5 stringWith16Bit_MD5Lower];
    NSString *finalMD5_16Upper = [afterMD5 stringWith16Bit_MD5Upper];
    NSLog(@"32bit 小写 %@", finalMD5_32Lower);
    NSLog(@"16bit 小写         %@", finalMD5_16Lower);
    NSLog(@"32bit 大写 %@", finalMD5_32Upper);
    NSLog(@"16bit 大写         %@", finalMD5_16Upper);
    
    /************* 2. SHA-1 ***************/
    NSString *afterSHA_1 = @"Hello";
    NSString *finalSHA_1 = [afterSHA_1 stringWithSHA_1];
    NSLog(@"SHA_1 %@", finalSHA_1);
    /************* 3.Base64 ***************/
    NSString *afterBase64 = @"Hello, 屌丝夫妇啥地方呢看看你是放大看了吗科目四端口吗领导了风格吗全日空";
    NSString *base64 = [afterBase64 stringWithBase64];
    NSLog(@"Base64 编码 %@", base64);
    NSString *finalBase64 = [base64 base64WithString];
    NSLog(@"Base64 解码 %@", finalBase64);
    /** 4.对称密码
     *  三种算法
     *  DES
     *  三重DES
     *  AES
     */
    NSString *afterDES = @"12345";
    NSString *desString = [afterDES stringWithDES];
    NSLog(@"DES 加密------%@", desString);
    
    NSString *source = [desString desWithString] ;
    NSLog(@"DES 解密------%@", source);
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
